	merge m:1 provid year month using "storms_emdat", nogenerate		
	merge m:1 provid year using "dohdata", nogenerate
	merge m:1 provid year month using "provyearcrops", nogenerate
	merge m:1 munid year month using "asfp_reshaped_allbcms", gen(_asfp)
	merge m:1 munid using  "muniareapop", gen(_muniarea) keepusing(landareahectares)
		drop if missing(hhid)
	
		
	*Muni controls
	merge m:1 munid using "munistats", keepusing(pctag hh_elec  hh_owntoilet ownland anydevice marrunder20 everborn munpop)
		drop if _merge==2
		drop _merge
		
	*Create per capita/area variable
	foreach var in eventviolent_mun total_mun {
		g pc_`var'=10000*`var'/munpop
		g pa_`var'=10000*`var'/landareahectares 
		
		foreach lookback in  270 a365  { 		
			cap noisily g pc_`var'_`lookback'=10000*`var'_`lookback'/munpop
			cap noisily g pa_`var'_`lookback'=10000*`var'_`lookback'/landareahectares 
		}
	}
		
	ds ratio*
	local ratiolist=r(varlist)
	foreach var in `ratiolist' {
		replace `var'=`var'*1000
	}
	
	sum year
	local min=r(min)
	g monthyear=(year-`min')*12+month
	
	ds *temp *prec
	global weathervars=r(varlist)
	foreach var in $weathervars {
		replace `var'=`var'/10
		g `var'2=`var'^2
		g `var'3=`var'^3
		g `var'4=`var'^4
	}
	
	replace childage=99 if childage==.
	
	
	xi i.childage i.edcat, prefix(d) noomit
			
	replace childage=. if childage==99
	g edcat3=edcat>3 if edcat<.
	recode hhsex (2=0)
		
	*Globals
	global weatherspec extmaxtemp extmaxtemp2 totprec totprec2 
	global c_none 
	global c_basic $weatherspec dchildage_0 dchildage_1 dchildage_2 dchildage_3 dchildage_4 dchildage_99 male  dedcat_0 dedcat_1 dedcat_2 dedcat_3 dedcat_4 dedcat_5 womanage womanage2
	global c_demogplus $weatherspec  dchildage_0 dchildage_1 dchildage_2 dchildage_3 dchildage_4 dchildage_99 womanage womanage2 male dedcat_0 dedcat_1 dedcat_2 dedcat_3 dedcat_4 dedcat_5 wealthscore wealthscore2 muslim hhsize hhkidsu5 hhwomen hhsex hhage nlivkids 	
	global c_mun $weatherspec dchildage_0 dchildage_1 dchildage_2 dchildage_3 dchildage_4 dchildage_99 womanage womanage2 male dedcat_0 dedcat_1 dedcat_2 dedcat_3 dedcat_4 dedcat_5 wealthscore wealthscore2 muslim hhsize hhkidsu5 hhwomen hhsex hhage nlivkids hh_elec hh_owntoilet marrunder20 ownland anydevice everborn
	global c_selection childage womanage male edcat3 wealthscore muslim hhsize hhkidsu5 hhwomen hhsex hhage nlivkids
	
		

	